home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / Usercp.php < prev   
Encoding:
PHP Script  |  2002-06-12  |  37.1 KB  |  1,191 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > UserCP functions
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 14th February 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24. $idx = new UserCP;
  25.  
  26. class UserCP {
  27.  
  28.     var $output     = "";
  29.     var $page_title = "";
  30.     var $nav        = array();
  31.     var $html       = "";
  32.     var $parser;
  33.  
  34.     var $member     = array();
  35.     var $m_group    = array();
  36.     
  37.     var $jump_html  = "";
  38.     var $parser     = "";
  39.     
  40.     var $links      = array();
  41.     
  42.     var $bio        = "";
  43.     var $notes      = "";
  44.     var $size       = "m";
  45.     
  46.     var $email      = "";
  47.     
  48.     var $lib;
  49.     
  50.     function UserCP() {
  51.         global $ibforums, $DB, $std, $print;
  52.         
  53.         require "./sources/lib/post_parser.php";
  54.         
  55.         $this->parser = new post_parser();
  56.         
  57.         //--------------------------------------------
  58.         // Get the emailer module
  59.         //--------------------------------------------
  60.         
  61.         require "./sources/lib/emailer.php";
  62.         
  63.         $this->email = new emailer();
  64.         
  65.         if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = 00;
  66.         
  67.         //--------------------------------------------
  68.         // Require the HTML and language modules
  69.         //--------------------------------------------
  70.         
  71.         $ibforums->lang = $std->load_words($ibforums->lang, 'lang_post'  , $ibforums->lang_id );
  72.         $ibforums->lang = $std->load_words($ibforums->lang, 'lang_ucp'   , $ibforums->lang_id );
  73.         
  74.         require "./sources/lib/usercp_functions.php";
  75.         
  76.         require "./Skin/".$ibforums->skin_id."/skin_ucp.php";
  77.         
  78.         $this->html = new skin_ucp();
  79.         
  80.         $this->base_url        = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
  81.         $this->base_url_nosess = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}";
  82.         
  83.         //--------------------------------------------
  84.         // Check viewing permissions, etc
  85.         //--------------------------------------------
  86.         
  87.         $this->member  = $ibforums->member;
  88.         
  89.         if (empty($this->member['id']))
  90.         {
  91.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
  92.         }
  93.         
  94.         // Get more member info..
  95.         
  96.         $DB->query("SELECT * from ibf_members WHERE id='".$this->member['id']."'");
  97.         $this->member = $DB->fetch_row();
  98.         
  99.         //-----------------------------------------------
  100.         // Format the links if we have any
  101.         //-----------------------------------------------
  102.         
  103.         $DB->query("SELECT links, notes, ta_size from ibf_member_extra WHERE id='".$this->member['id']."'");
  104.         $row = $DB->fetch_row();
  105.         
  106.         $this->links = $row['links'];
  107.         $this->notes = $row['notes'];
  108.         $this->size  = $row['ta_size'] ? $row['ta_size'] : $this->size;
  109.         
  110.         // We have a single pull down menu for our "Quick Click" stuff
  111.         // The JS uses a simple split command to determine if the link
  112.         // is onsite, or offsite. If it's onsite, it'll have a preceeding
  113.         // element of 0, if it's onsite it'll have an element of 1. If it's
  114.         // offsite, we open a new window via JS.
  115.         // Yes, I feel quite clever. :P
  116.         
  117.         $links = "";
  118.         
  119.         if ($this->links)
  120.         {
  121.             $link_array = unserialize(stripslashes($this->links));
  122.             
  123.             reset($link_array);
  124.             
  125.             $links  = "<option value='-1'>----------------</option>\n<option value='-1'>{$ibforums->lang['qc_your_links']}</option>\n";
  126.             $links .= "<option value='-1'>----------------</option>\n";
  127.             
  128.             foreach ( $link_array as $k => $v )
  129.             {
  130.                 $url  = $v[0];
  131.                 $desc = $v[1];
  132.                 
  133.                 if ($url != "" and $desc != "")
  134.                 {
  135.                     if (strlen($desc) > 45)
  136.                     {
  137.                         $desc = substr( $desc, 0, 42 ) . '...';
  138.                     }
  139.                     
  140.                     $links .= "<option value='1|$url'>$desc</option>\n";
  141.                     
  142.                 }
  143.             }
  144.         }
  145.         
  146.         //--------------------------------------------
  147.         // Print the top button menu
  148.         //--------------------------------------------
  149.         
  150.         $print->add_output( $this->html->Menu_bar($this->base_url) );
  151.         
  152.         $this->lib    = new usercp_functions(&$this);
  153.         
  154.         
  155.         //--------------------------------------------
  156.         // What to do?
  157.         //--------------------------------------------
  158.         
  159.         
  160.         switch($ibforums->input['CODE']) {
  161.             case '00':
  162.                 $this->splash();
  163.                 break;
  164.             case '01':
  165.                 $this->personal();
  166.                 break;
  167.             //------------------------------
  168.             case '02':
  169.                 $this->email_settings();
  170.                 break;
  171.             case '03':
  172.                 $this->do_email_settings();
  173.                 break;
  174.             //------------------------------
  175.             case '04':
  176.                 $this->board_prefs();
  177.                 break;
  178.             case '05':
  179.                 $this->do_board_prefs();
  180.                 break;
  181.             //------------------------------
  182.             case '06':
  183.                 $this->skin_langs();
  184.                 break;
  185.             case '07':
  186.                 $this->do_skin_langs();
  187.                 break;
  188.             //------------------------------
  189.             case '08':
  190.                 $this->email_change();
  191.                 break;
  192.             case '09':
  193.                 $this->do_email_change();
  194.                 break;
  195.             //------------------------------
  196.             case '21':
  197.                 $this->do_personal();
  198.                 break;
  199.             case '20':
  200.                 $this->update_notepad();
  201.                 break;
  202.             //------------------------------
  203.             case '22':
  204.                 $this->signature();
  205.                 break;
  206.             case '23':
  207.                 $this->do_signature();
  208.                 break;
  209.             //------------------------------
  210.             case '24':
  211.                 $this->avatar();
  212.                 break;
  213.             case '25':
  214.                 $this->do_avatar();
  215.                 break;
  216.             //------------------------------
  217.             case '26':
  218.                 $this->tracker();
  219.                 break;
  220.             case '27':
  221.                 $this->do_delete_tracker();
  222.                 break;
  223.             //------------------------------
  224.             case '28':
  225.                 $this->pass_change();
  226.                 break;
  227.             case '29':
  228.                 $this->do_pass_change();
  229.                 break;
  230.             //------------------------------
  231.             default:
  232.                 $this->splash();
  233.                 break;
  234.         }
  235.         
  236.         // If we have any HTML to print, do so...
  237.         
  238.         $fj = $std->build_forum_jump();
  239.         $fj = preg_replace( "!#Forum Jump#!", $ibforums->lang['forum_jump'], $fj);
  240.         
  241.         $this->output .= $this->html->CP_end();
  242.         
  243.         $this->output .= $this->html->forum_jump($fj, $links);
  244.         
  245.         $print->add_output("$this->output");
  246.         $print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 1, NAV => $this->nav ) );
  247.             
  248.      }
  249.      
  250.      
  251.      //*******************************************************************/
  252.      //| pass change:
  253.      //|
  254.      //| Change the users password.
  255.      //*******************************************************************/
  256.      
  257.      function pass_change()
  258.      {
  259.          global $ibforums, $DB, $std;
  260.          
  261.          $this->output    .= $this->html->pass_change();
  262.          $this->page_title = $ibforums->lang['t_welcome'];
  263.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  264.          
  265.      }
  266.      
  267.      function do_pass_change()
  268.      {
  269.          global $ibforums, $DB, $std, $HTTP_POST_VARS, $print;
  270.          
  271.          if ( $HTTP_POST_VARS['current_pass'] == "" or empty($HTTP_POST_VARS['current_pass']) )
  272.          {
  273.              $std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
  274.          }
  275.          
  276.          //--------------------------------------------
  277.          
  278.          $cur_pass = trim($ibforums->input['current_pass']);
  279.          $new_pass = trim($ibforums->input['new_pass_1']);
  280.          $chk_pass = trim($ibforums->input['new_pass_2']);
  281.          
  282.          //--------------------------------------------
  283.          
  284.          if ( ( empty($new_pass) ) or ( empty($chk_pass) ) )
  285.          {
  286.              $std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
  287.          }
  288.          
  289.          //--------------------------------------------
  290.          
  291.          if ($new_pass != $chk_pass)
  292.          {
  293.              $std->Error( array( 'LEVEL' => 1, 'MSG' => 'pass_no_match' ) );
  294.          }
  295.          
  296.          //--------------------------------------------
  297.          
  298.          if (md5($cur_pass) != $this->member['password'])
  299.          {
  300.              $std->Error( array( 'LEVEL' => 1, 'MSG' => 'wrong_pass' ) );
  301.          }
  302.          
  303.          //--------------------------------------------
  304.          
  305.          $md5_pass = md5($new_pass);
  306.          
  307.          //--------------------------------------------
  308.          // Update the DB
  309.          //--------------------------------------------
  310.          
  311.          $DB->query("UPDATE ibf_members SET password='$md5_pass' WHERE id='".$this->member['id']."'");
  312.          
  313.          $DB->query("UPDATE ibf_sessions SET member_pass='$md5_pass' WHERE id='".$this->session_id."' and member_id='".$this->member['id']."'");
  314.          
  315.          //--------------------------------------------
  316.          // Update the cookie..
  317.          //--------------------------------------------
  318.          
  319.          $std->my_setcookie( 'pass_hash', $md5_pass, 1 );
  320.          
  321.          //--------------------------------------------
  322.          // Redirect...
  323.          //--------------------------------------------
  324.          
  325.          $print->redirect_screen( $ibforums->lang['pass_redirect'], 'act=UserCP&CODE=00' );
  326.          
  327.      }
  328.      
  329.      
  330.      //*******************************************************************/
  331.      //| email change:
  332.      //|
  333.      //| Change the users email address
  334.      //*******************************************************************/
  335.      
  336.      function email_change() {
  337.          global $ibforums, $DB, $std;
  338.          
  339.          $txt = $ibforums->lang['ce_current'].$this->member['email'];
  340.          
  341.          if ($ibforums->vars['reg_auth_type'])
  342.          {
  343.              $txt .= $ibforums->lang['ce_auth'];
  344.          }
  345.          
  346.          $this->output    .= $this->html->email_change($txt);
  347.          $this->page_title = $ibforums->lang['t_welcome'];
  348.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  349.          
  350.      }
  351.      
  352.      function do_email_change()
  353.      {
  354.          global $ibforums, $DB, $std, $HTTP_POST_VARS, $print;
  355.          
  356.          if ($HTTP_POST_VARS['in_email_1'] == "")
  357.          {
  358.              $std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
  359.          }
  360.          
  361.          if ($HTTP_POST_VARS['in_email_2'] == "")
  362.          {
  363.              $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
  364.          }
  365.          
  366.          //--------------------------------------------
  367.          
  368.          $email_one    = strtolower( trim($ibforums->input['in_email_1']) );
  369.          $email_two    = strtolower( trim($ibforums->input['in_email_2']) );
  370.          
  371.          if ($email_one != $email_two)
  372.         {
  373.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'email_addy_mismatch' ) );
  374.         }
  375.         
  376.         //--------------------------------------------
  377.         
  378.         $email_one = $std->clean_email($email_one);
  379.         
  380.         if ( $email_one == "" ) {
  381.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_email' ) );
  382.         }
  383.         
  384.         //--------------------------------------------
  385.         
  386.         if (! $ibforums->vars['allow_dup_email'] )
  387.         {
  388.             $DB->query("SELECT id FROM ibf_members WHERE email='".$email_one."'");
  389.             $email_check = $DB->fetch_row();
  390.             if ($email_check['id'])
  391.             {
  392.                 $std->Error( array( LEVEL => 1, MSG => 'email_exists' ) );
  393.             }
  394.         }
  395.         
  396.         if ($ibforums->vars['reg_auth_type'])
  397.         {
  398.             $validate_key = $std->make_password();
  399.             
  400.             //--------------------------------------------
  401.             // Update the new email, but enter a validation key
  402.             // and put the member in "awaiting authorisation"
  403.             // and send an email..
  404.             //--------------------------------------------
  405.             
  406.             $DB->query("UPDATE ibf_members SET validate_key='$validate_key', prev_group='".$this->member['mgroup']."', mgroup='".$ibforums->vars['auth_group']."', email='$email_one' WHERE id='".$this->member['id']."'");
  407.             
  408.             // Update their session with the new member group
  409.             
  410.             if ($ibforums->session_id)
  411.             {
  412.                 $DB->query("UPDATE ibf_sessions SET member_name='', member_id='0', member_pass='', member_group='".$ibforums->vars['guest_group']."' WHERE member_id='".$this->member['id']."' and id='".$ibforums->session_id."'");
  413.              }
  414.              
  415.              // Kill the cookies to stop auto log in
  416.              
  417.              $std->my_setcookie( 'pass_hash'  , '-1', 0 );
  418.              $std->my_setcookie( 'member_id'  , '-1', 0 );
  419.              $std->my_setcookie( 'session_id' , '-1', 0 );
  420.              
  421.              // Dispatch the mail, and return to the activate form.
  422.              
  423.              $this->email->get_template("newemail");
  424.                 
  425.             $this->email->build_message( array(
  426.                                                 'NAME'         => $this->member['name'],
  427.                                                 'MAN_LINK'     => $this->base_url_nosess."?act=Reg&CODE=07",
  428.                                                 'ID'           => $this->member['id'],
  429.                                                 'CODE'         => $validate_key,
  430.                                               )
  431.                                         );
  432.                                         
  433.             $this->email->subject = $ibforums->lang['lp_subject'].' '.$ibforums->vars['board_name'];
  434.             $this->email->to      = $email_one;
  435.             
  436.             $this->email->send_mail();
  437.             
  438.             $print->redirect_screen( $ibforums->lang['ce_redirect'], 'act=Reg&CODE=07' );
  439.         }
  440.         else
  441.         {
  442.             // No authorisation needed, change email addy and return
  443.             
  444.             $DB->query("UPDATE ibf_members SET email='$email_one' WHERE id='".$this->member['id']."'");
  445.             
  446.             $std->boink_it($this->base_url."&act=UserCP&CODE=08");
  447.             
  448.         }
  449.      }
  450.      
  451.      //*******************************************************************/
  452.      //| tracker:
  453.      //|
  454.      //| Print the subscribed topics listings
  455.      //*******************************************************************/
  456.      
  457.      function tracker() {
  458.          global $ibforums, $DB, $std, $print;
  459.          
  460.          $this->output .= $this->html->subs_header();
  461.          
  462.          //----------------------------------------------------------
  463.          // Query the DB for the subby toppy-ics - at the same time
  464.          // we get the forum and topic info, 'cos we rule.
  465.          //----------------------------------------------------------
  466.          
  467.          $DB->query("SELECT s.trid, s.member_id, s.topic_id, s.last_sent, s.start_date as track_started, t.*, f.id as forum_id, f.name as forum_name, f.read_perms "
  468.                    ."FROM ibf_tracker s, ibf_topics t, ibf_forums f "
  469.                    ."WHERE s.member_id='".$this->member['id']."' AND t.tid=s.topic_id AND f.id=t.forum_id "
  470.                    ."ORDER BY t.last_post DESC");
  471.                    
  472.          if ( $DB->get_num_rows() )
  473.          {
  474.          
  475.              while( $topic = $DB->fetch_row() )
  476.              {
  477.              
  478.                 $topic['last_poster'] = ($topic['last_poster_id'] != 0)
  479.                                         ? "<b><a href='{$this->base_url}&act=Profile&CODE=03&MID={$topic['last_poster_id']}'>{$topic['last_poster_name']}</a></b>"
  480.                                         : "-".$topic['last_poster_name']."-";
  481.                                     
  482.                 $topic['starter']     = ($topic['starter_id']     != 0)
  483.                                         ? "<a href='{$this->base_url}&act=Profile&CODE=03&MID={$topic['starter_id']}'>{$topic['starter_name']}</a>"
  484.                                         : "-".$topic['starter_name']."-";
  485.              
  486.                 if ($topic['poll_state'])
  487.                 {
  488.                     $topic['prefix']     = $ibforums->vars['pre_polls'].' ';
  489.                 }
  490.             
  491.                 $topic['folder_icon']    = $std->folder_icon($topic);
  492.                 
  493.                 $topic['topic_icon']     = $topic['icon_id']  ? '<img src="'.$ibforums->vars[html_url] . '/icon' . $topic['icon_id'] . '.gif" border="0" alt="">'
  494.                                          : ' ';
  495.                                                                       
  496.                 if ($topic['pinned'])
  497.                 {
  498.                     $topic['topic_icon']       = $ibforums->skin['B_PIN'];
  499.                 }
  500.                 
  501.                 $topic['start_date'] = $std->get_date( $topic['track_started'], 'LONG' );
  502.                 
  503.                 if ($topic['description'])
  504.                 {
  505.                     $topic['description'] = $topic['description'].'<br>';
  506.                 }
  507.             
  508.             
  509.                 $pages = 1;
  510.                 
  511.                 if ($topic['posts'])
  512.                 {
  513.                     if ( (($topic['posts'] + 1) % $ibforums->vars['display_max_posts']) == 0 )
  514.                     {
  515.                         $pages = ($topic['posts'] + 1) / $ibforums->vars['display_max_posts'];
  516.                     }
  517.                     else
  518.                     {
  519.                         $number = ( ($topic['posts'] + 1) / $ibforums->vars['display_max_posts'] );
  520.                         $pages = ceil( $number);
  521.                     }
  522.                     
  523.                 }
  524.                 
  525.                 if ($pages > 1) {
  526.                     $topic['PAGES'] = "<span id='small'>({$ibforums->lang['topic_sp_pages']} ";
  527.                     for ($i = 0 ; $i < $pages ; ++$i ) {
  528.                         $real_no = $i * $ibforums->vars['display_max_posts'];
  529.                         $page_no = $i + 1;
  530.                         if ($page_no == 4) {
  531.                             $topic['PAGES'] .= "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&st=" . ($pages - 1) * $ibforums->vars['display_max_posts'] . "'>...$pages </a>";
  532.                             break;
  533.                         } else {
  534.                             $topic['PAGES'] .= "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&st=$real_no'>$page_no </a>";
  535.                         }
  536.                     }
  537.                     $topic['PAGES'] .= ")</span>";
  538.                 }
  539.                 
  540.                 if ($topic['posts'] < 0) $topic['posts'] = 0;
  541.                 
  542.                 // Do the quick goto last page icon stuff
  543.                 
  544.                 $topic['last_post_date']  = $std->get_date( $topic['last_post'], 'LONG' );
  545.                 
  546.                 $this->output .= $this->html->subs_row($topic);
  547.             }
  548.             
  549.         }
  550.         else
  551.         {
  552.             // no results
  553.         }
  554.             
  555.         $this->output .= $this->html->subs_end();
  556.          
  557.         $this->page_title = $ibforums->lang['t_welcome'];
  558.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  559.          
  560.      }
  561.      
  562.      function do_delete_tracker() {
  563.          global $ibforums, $std, $DB;
  564.          
  565.          //--------------------------------------
  566.          // Get the ID's to delete
  567.          //--------------------------------------
  568.          
  569.          if ($ibforums->input['request_method'] != 'post')
  570.          {
  571.              $std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
  572.          }
  573.          
  574.          $ids = array();
  575.          
  576.          foreach ($ibforums->input as $key => $value)
  577.          {
  578.              if ( preg_match( "/^id-(\d+)$/", $key, $match ) )
  579.              {
  580.                  if ($ibforums->input[$match[0]])
  581.                  {
  582.                      $ids[] = $match[1];
  583.                  }
  584.              }
  585.          }
  586.          
  587.          if ( count($ids) > 0 )
  588.          {
  589.              $DB->query("DELETE from ibf_tracker WHERE member_id='".$this->member['id']."' and trid IN (".implode( ",", $ids ).")");
  590.          }
  591.              
  592.          $std->boink_it($this->base_url."&act=UserCP&CODE=26");
  593.          
  594.      }
  595.      
  596.      //*******************************************************************/
  597.      //| SKIN LANGS:
  598.      //|
  599.      //| Change skin and languages prefs.
  600.      //*******************************************************************/
  601.      
  602.      function skin_langs() {
  603.          global $ibforums, $DB, $std, $print;
  604.          
  605.          // A serialized array holds our langauge settings.
  606.          // The array is: 1 => array( '$dir', '$name'), 2 => ... etc
  607.          
  608.          
  609.          $lang_array = array();
  610.          
  611.          $lang_select = "<select name='u_language' class='forminput'>\n";
  612.         
  613.         $DB->query("SELECT ldir, lname FROM ibf_languages");
  614.         
  615.         while ( $l = $DB->fetch_row() )
  616.         {
  617.             $lang_select .= $l['ldir'] == $this->member['language'] ? "<option value='{$l['ldir']}' selected>{$l['lname']}</option>"
  618.                                                                      : "<option value='{$l['ldir']}'>{$l['lname']}</option>";
  619.         }
  620.          
  621.          $lang_select .= "</select>";
  622.          
  623.          $this->output .= $this->html->skin_lang_header($lang_select);
  624.          
  625.          if ($ibforums->vars['allow_skins'] == 1)
  626.          {
  627.              
  628.              $DB->query("SELECT uid, sid, sname FROM ibf_skins WHERE hidden <> 1");
  629.              
  630.              if ( $DB->get_num_rows() )
  631.              {
  632.              
  633.                 $skin_select = "<select name='u_skin' class='forminput'>\n";
  634.             
  635.                 while ( $s = $DB->fetch_row() )
  636.                 {
  637.                     $skin_select .= $s['sid'] == $this->member['skin'] ? "<option value='{$s['sid']}' selected>{$s['sname']}</option>"
  638.                                                                        : "<option value='{$s['sid']}'>{$s['sname']}</option>";
  639.                 }
  640.                 
  641.                 $skin_select .= "</select>";
  642.                 
  643.             }
  644.         
  645.             $this->output .= $this->html->settings_skin($skin_select);
  646.         }
  647.         
  648.         $this->output .= $this->html->skin_lang_end();
  649.          
  650.          $this->page_title = $ibforums->lang['t_welcome'];
  651.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  652.          
  653.      }
  654.      
  655.      function do_skin_langs() {
  656.      
  657.          $this->lib->do_skin_langs();
  658.          
  659.      }
  660.      
  661.      
  662.      //*******************************************************************/
  663.      //| BOARD PREFS:
  664.      //|
  665.      //| Set up view avatar, sig, time zone, etc.
  666.      //*******************************************************************/
  667.      
  668.      function board_prefs() {
  669.          global $ibforums, $DB, $std, $print;
  670.          
  671.          $time = $std->get_date( time(), 'LONG' );
  672.          
  673.          // Do we have a user stored offset, or use the board default:
  674.          
  675.          $offset = ( $ibforums->member['time_offset'] != "" ) ? $ibforums->member['time_offset'] : $ibforums->vars['time_offset'];
  676.          
  677.          $time_select = "<select name='u_timezone' class='forminput'>";
  678.          
  679.          // Loop through the langauge time offsets and names to build our
  680.          // HTML jump box.
  681.          
  682.          foreach( $ibforums->lang as $off => $words )
  683.          {
  684.              if (preg_match("/^time_(\S+)$/", $off, $match))
  685.              {
  686.                 $time_select .= $match[1] == $offset ? "<option value='{$match[1]}' selected>$words</option>"
  687.                                                      : "<option value='{$match[1]}'>$words</option>";
  688.              }
  689.          }
  690.          
  691.          $time_select .= "</select>";
  692.          
  693.          // Print out the header..
  694.          
  695.          if ($ibforums->member['dst_in_use'])
  696.          {
  697.              $dst_check = 'checked';
  698.          }
  699.          else
  700.          {
  701.              $dst_check = '';
  702.          }
  703.          
  704.          $this->output .= $this->html->settings_header($this->member, $time_select, $time, $dst_check);
  705.          
  706.          $hide_sess = $std->my_getcookie('hide_sess');
  707.          
  708.          // View avatars, signatures and images..
  709.          
  710.          $view_ava  = "<select name='VIEW_AVS' class='forminput'>";
  711.          $view_sig  = "<select name='VIEW_SIGS' class='forminput'>";
  712.          $view_img  = "<select name='VIEW_IMG' class='forminput'>";
  713.          $view_pop  = "<select name='DO_POPUP' class='forminput'>";
  714.          $html_sess = "<select name='HIDE_SESS' class='forminput'>";
  715.          
  716.          $view_ava .= $this->member['view_avs'] ? "<option value='1' selected>".$ibforums->lang['yes']."</option>\n<option value='0'>".$ibforums->lang['no']."</option>"
  717.                                                 : "<option value='1'>".$ibforums->lang['yes']."</option>\n<option value='0' selected>".$ibforums->lang['no']."</option>";
  718.          
  719.          $view_sig .= $this->member['view_sigs'] ? "<option value='1' selected>".$ibforums->lang['yes']."</option>\n<option value='0'>".$ibforums->lang['no']."</option>"
  720.                                                 : "<option value='1'>".$ibforums->lang['yes']."</option>\n<option value='0' selected>".$ibforums->lang['no']."</option>";
  721.          
  722.          $view_img .= $this->member['view_img'] ? "<option value='1' selected>".$ibforums->lang['yes']."</option>\n<option value='0'>".$ibforums->lang['no']."</option>"
  723.                                                 : "<option value='1'>".$ibforums->lang['yes']."</option>\n<option value='0' selected>".$ibforums->lang['no']."</option>";
  724.                                                
  725.          $view_pop .= $this->member['view_pop'] ? "<option value='1' selected>".$ibforums->lang['yes']."</option>\n<option value='0'>".$ibforums->lang['no']."</option>"
  726.                                                 : "<option value='1'>".$ibforums->lang['yes']."</option>\n<option value='0' selected>".$ibforums->lang['no']."</option>";
  727.          
  728.          $html_sess .= $hide_sess == 1          ? "<option value='1' selected>".$ibforums->lang['yes']."</option>\n<option value='0'>".$ibforums->lang['no']."</option>"
  729.                                                 : "<option value='1'>".$ibforums->lang['yes']."</option>\n<option value='0' selected>".$ibforums->lang['no']."</option>";
  730.          
  731.          
  732.          $this->output .= $this->html->settings_end( array ( 'IMG'  => $view_img."</select>",
  733.                                                              'SIG'  => $view_sig."</select>",
  734.                                                              'AVA'  => $view_ava."</select>",
  735.                                                              'POP'  => $view_pop."</select>",
  736.                                                              'SESS' => $html_sess."</select>",
  737.                                                    )       );
  738.          
  739.          $this->page_title = $ibforums->lang['t_welcome'];
  740.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  741.          
  742.      }
  743.      
  744.  
  745.      function do_board_prefs() {
  746.      
  747.          $this->lib->do_board_prefs();
  748.          
  749.      }
  750.      
  751.      //*******************************************************************/
  752.      //| EMAIL SETTINGS:
  753.      //|
  754.      //| Set up the email stuff.
  755.      //*******************************************************************/
  756.      
  757.      function email_settings() {
  758.          global $ibforums, $DB, $std, $print;
  759.          
  760.          // PM_REMINDER: First byte = Email PM when received new
  761.          //               Second byte= Show pop-up when new PM received
  762.                          
  763.          
  764.          $info = array();
  765.          
  766.          foreach ( array(hide_email, allow_admin_mails, email_full, email_pm) as $k )
  767.          {
  768.              if (!empty($this->member[ $k ]))
  769.              {
  770.                  $info[$k] = 'checked';
  771.              }
  772.          }
  773.          
  774.          $this->output .= $this->html->email($info);
  775.          
  776.          $this->page_title = $ibforums->lang['t_welcome'];
  777.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  778.          
  779.      }
  780.      
  781.      function do_email_settings() {
  782.      
  783.          $this->lib->do_email_settings();
  784.          
  785.      }
  786.      
  787.      
  788.      
  789.      //*******************************************************************/
  790.      //| AVATAR:
  791.      //|
  792.      //| Displays the avatar choices
  793.      //*******************************************************************/
  794.      
  795.      function avatar() {
  796.          global $ibforums, $DB, $std, $print;
  797.          
  798.          //------------------------------------------
  799.          // Organise the dimensions
  800.          //------------------------------------------
  801.          
  802.          list( $this->member['AVATAR_WIDTH'] , $this->member['AVATAR_HEIGHT']  ) = explode ("x", $this->member['avatar_size']);
  803.          list( $ibforums->vars['av_width']   , $ibforums->vars['av_height']    ) = explode ("x", $ibforums->vars['avatar_dims']);
  804.          list( $w, $h ) = explode ( "x", $ibforums->vars['avatar_def'] );
  805.          
  806.          //------------------------------------------
  807.          // Get the users current avatar to display
  808.          //------------------------------------------
  809.          
  810.          $my_avatar = $std->get_avatar( $this->member['avatar'], 1, $this->member['avatar_size'] );
  811.          
  812.          $my_avatar = $my_avatar ? $my_avatar : 'noavatar';
  813.          
  814.          //------------------------------------------
  815.          // Get the avatar gallery
  816.          //------------------------------------------
  817.          
  818.          $avatar_gallery = array();
  819.          
  820.          $dh = opendir( $ibforums->vars['html_dir'].'avatars' );
  821.          while ( $file = readdir( $dh ) )
  822.          {
  823.              if ( !preg_match( "/^..?$|^index/i", $file ) )
  824.              {
  825.                  $avatar_gallery[] = $file;
  826.              }
  827.          }
  828.          closedir( $dh );
  829.          
  830.          //------------------------------------------
  831.          // Get the avatar gallery selected
  832.          //------------------------------------------
  833.          
  834.          $url_avatar = "http://";
  835.          
  836.          $avatar_gall_selected = 'noavatar.gif';
  837.          
  838.          $uploaded_avatar = 0;
  839.          
  840.          if ( ($this->member['avatar'] != "") and ($this->member['avatar'] != "noavatar") )
  841.          {
  842.              if ( preg_match( "/^upload:/", $this->member['avatar'] ) )
  843.              {
  844.                  $uploaded_avatar = 1;
  845.              }
  846.             else if ( !preg_match( "/^http/i", $this->member['avatar'] ) )
  847.             {
  848.                 $avatar_gall_selected = $this->member['avatar'];
  849.             }
  850.             else
  851.             {
  852.                 $url_avatar = $this->member['avatar'];
  853.             }
  854.          }
  855.          
  856.          $allowed_ext = '.' . implode (' .', explode( "|", $ibforums->vars['avatar_ext'] ) );
  857.          
  858.          $show_avatar = "<img src='{$ibforums->vars['AVATARS_URL']}/$avatar_gall_selected' name='show_avatar' width='$w' height='$h' border='0' hspace='15'>";
  859.          
  860.          //------------------------------------------
  861.          // Organise the avatar select box
  862.          //------------------------------------------
  863.          
  864.          $av_html = "<select name='gallery_list' size='10' onchange=\"showavatar('{$ibforums->vars['AVATARS_URL']}/')\" class='forminput'>";
  865.          
  866.          foreach ($avatar_gallery as $v )
  867.          {
  868.              $view = preg_replace( "/\.(\S+)$/", "", $v );
  869.              $av_html .= $v == $avatar_gall_selected ? "<option value='$v' selected>$view</option>\n"
  870.                                                      : "<option value='$v'>$view</option>\n";
  871.          }
  872.          
  873.          $av_html .= "</select>";
  874.          
  875.          $formextra   = "";
  876.          $hidden_field = "";
  877.          
  878.          if ($ibforums->member['g_avatar_upload'] == 1)
  879.          {
  880.              $formextra    = " enctype='multipart/form-data'";
  881.             $hidden_field = "<input type='hidden' name='MAX_FILE_SIZE' value='".($ibforums->vars['avup_size_max']*1024)."'>";
  882.         }
  883.          
  884.          $this->output .= $this->html->personal_avatar( array (
  885.                                                                  'MEMBER'   => $this->member,
  886.                                                                  'AVATARS'  => $av_html,
  887.                                                                  'SHOW_AVS' => $show_avatar,
  888.                                                                  'CUR_AV'   => $my_avatar
  889.                                                       )  , $formextra, $hidden_field     );
  890.          if ($ibforums->vars['avatar_url'])
  891.          {                                             
  892.              $this->output .= $this->html->personal_avatar_URL( $this->member, $url_avatar, $allowed_ext );
  893.              
  894.              $text = $uploaded_avatar == 1 ? $ibforums->lang['avup_yes'] : $ibforums->lang['avup_no'];
  895.              
  896.              if ($ibforums->member['g_avatar_upload'] == 1)
  897.              {
  898.                  $this->output = preg_replace( "/<!-- IBF\.UPLOAD_AVATAR -->/e", "\$this->html->avatar_upload_field(\$text)", $this->output );
  899.              }
  900.              
  901.          }
  902.          
  903.          $this->output .= $this->html->personal_avatar_end();
  904.          
  905.          $this->page_title = $ibforums->lang['t_welcome'];
  906.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  907.          
  908.      }
  909.      
  910.      function do_avatar() {
  911.      
  912.          $this->lib->do_avatar();
  913.          
  914.      }
  915.      
  916.      //*******************************************************************/
  917.      //| SIGNATURE:
  918.      //|
  919.      //| Displays the signature form
  920.      //*******************************************************************/
  921.      
  922.      function signature() {
  923.          global $ibforums, $DB, $std, $print;
  924.          
  925.         $t_sig = $this->parser->unconvert( $this->member['signature'], $ibforums->vars['sig_allow_ibc'], $ibforums->vars['sig_allow_html'] );
  926.         
  927.         $ibforums->lang['the_max_length'] = $ibforums->vars['max_sig_length'] ? $ibforums->vars['max_sig_length'] : 0;
  928.          
  929.          $this->output .= $this->html->signature($this->member['signature'], $t_sig);
  930.          
  931.          $this->page_title = $ibforums->lang['t_welcome'];
  932.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  933.          
  934.      }
  935.      
  936.      function do_signature() {
  937.      
  938.          $this->lib->do_signature();
  939.      
  940.      }
  941.      
  942.      //*******************************************************************/
  943.      //| PERSONAL:
  944.      //|
  945.      //| Displays the personal info form
  946.      //*******************************************************************/
  947.      
  948.      function personal() {
  949.          global $ibforums, $DB, $std, $print;
  950.          
  951.          //-----------------------------------------------
  952.         // Check to make sure that we can edit profiles..
  953.         //-----------------------------------------------
  954.         
  955.         if (empty($ibforums->member['g_edit_profile']))
  956.         {
  957.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'cant_use_feature' ) );
  958.         }
  959.         
  960.         //-----------------------------------------------
  961.         // Format the birthday drop boxes..
  962.         //-----------------------------------------------
  963.         
  964.         $date = getdate();
  965.         
  966.         $day  = "<option value='0'>--</option>";
  967.         $mon  = "<option value='0'>--</option>";
  968.         $year = "<option value='0'>--</option>";
  969.         
  970.         for ( $i = 1 ; $i < 32 ; $i++ )
  971.         {
  972.             $day .= "<option value='$i'";
  973.             
  974.             $day .= $i == $this->member['bday_day'] ? "selected>$i</option>" : ">$i</option>";
  975.         }
  976.         
  977.         for ( $i = 1 ; $i < 13 ; $i++ )
  978.         {
  979.             $mon .= "<option value='$i'";
  980.             
  981.             $mon .= $i == $this->member['bday_month'] ? "selected>{$ibforums->lang['month'.$i]}</option>" : ">{$ibforums->lang['month'.$i]}</option>";
  982.         }
  983.         
  984.         $i = $date['year'] - 1;
  985.         $j = $date['year'] - 100;
  986.         
  987.         for ( $i ; $j < $i ; $i-- )
  988.         {
  989.             $year .= "<option value='$i'";
  990.             
  991.             $year .= $i == $this->member['bday_year'] ? "selected>$i</option>" : ">$i</option>";
  992.         }
  993.         
  994.         //-----------------------------------------------
  995.         // Format the interest / location boxes
  996.         //-----------------------------------------------
  997.         
  998.         $this->member['location']  = $this->parser->unconvert( $this->member['location']  );
  999.          $this->member['interests'] = $this->parser->unconvert( $this->member['interests'] );
  1000.          
  1001.          //-----------------------------------------------
  1002.         // Format the siggie (no, not ciggie - smoking is
  1003.         // bad boys and girls)
  1004.         //-----------------------------------------------
  1005.         
  1006.         if ($ibforums->vars['sig_allow_html'])
  1007.         {
  1008.             $this->member['signature'] = $std->text_tidy($this->member['signature']);
  1009.         }
  1010.         else
  1011.         {
  1012.             $this->member['signature'] = $this->parser->unconvert($this->member['signature']);
  1013.         }
  1014.         
  1015.         //-----------------------------------------------
  1016.         // Suck up the HTML and swop some tags if need be
  1017.         //-----------------------------------------------
  1018.         
  1019.         $this->output .= $this->html->personal_panel($this->member);
  1020.         
  1021.         if ( ($ibforums->vars['post_titlechange']) and ($this->member['posts'] > $ibforums->vars['post_titlechange']) )
  1022.         {
  1023.             $t_html = $this->html->member_title($this->member['title']);
  1024.             $this->output = preg_replace( "/<!--\{MEMBERTITLE\}-->/", $t_html, $this->output );
  1025.         }
  1026.         
  1027.         $t_html = $this->html->birthday($day, $mon, $year);
  1028.         
  1029.         $this->output = preg_replace( "/<!--\{BIRTHDAY\}-->/", $t_html, $this->output );
  1030.         
  1031.         $this->page_title = $ibforums->lang['t_welcome'];
  1032.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  1033.         
  1034.     }
  1035.     
  1036.     function do_personal() {
  1037.         
  1038.         // Hand it straight to our library to keep this code clean and compact.
  1039.         
  1040.         $this->lib->do_profile();
  1041.         
  1042.     }
  1043.     
  1044.     
  1045.     
  1046.      
  1047.      //*******************************************************************/
  1048.      //| SPLASH:
  1049.      //|
  1050.      //| Displays the intro screen
  1051.      //*******************************************************************/
  1052.      
  1053.      function splash() {
  1054.          global $ibforums, $DB, $std, $print;
  1055.          
  1056.         //-----------------------------------------------
  1057.         // Format the basic data
  1058.         //-----------------------------------------------
  1059.         
  1060.         $info['MEMBER_EMAIL']    = $this->member['email'];
  1061.         $info['DATE_REGISTERED'] = $std->get_date( $this->member['joined'], 'LONG' );
  1062.         $info['MEMBER_POSTS']    = $this->member['posts'];
  1063.         
  1064.         $info['DAILY_AVERAGE']   = $ibforums->lang['no_posts'];
  1065.         
  1066.         if ($this->member['posts'] > 0 )
  1067.         {
  1068.             $diff = time() - $this->member['joined'];
  1069.             $days = ($diff / 3600) / 24;
  1070.             $days = $days < 1 ? 1 : $days;
  1071.             $info['DAILY_AVERAGE']  = sprintf('%.2f', ($this->member['posts'] / $days) );
  1072.         }
  1073.         
  1074.         //---------------------------------------------
  1075.          // Get the number of messages we have in total.
  1076.          //---------------------------------------------
  1077.          
  1078.          $DB->query("SELECT COUNT(*) as msg_total FROM ibf_messages WHERE member_id='".$this->member['id']."'");
  1079.          $total = $DB->fetch_row();
  1080.          
  1081.          //---------------------------------------------
  1082.          // Make sure we've not exceeded our alloted allowance.
  1083.          //---------------------------------------------
  1084.          
  1085.          $info['full_messenger'] = "";
  1086.          $info['full_percent']   = "";
  1087.          $info['space_free']     = "Unlimited";
  1088.          $info['total_messages'] = $total['msg_total'];
  1089.          
  1090.          if ($ibforums->vars['max_messages'] > 0)
  1091.          {
  1092.              if ($total['msg_total'] >= $ibforums->vars['max_messages'])
  1093.              {
  1094.                  $info['full_messenger'] = "<span id='highlight'>".$ibforums->lang['folders_full']."</span>";
  1095.              }
  1096.              
  1097.              $info['full_percent'] = $total['msg_total'] ? sprintf( "%.0f", ( ($total['msg_total'] / $ibforums->vars['max_messages']) * 100) ) : 0;
  1098.              $info['full_percent'] = "(". $info['full_percent'] .'% '. $ibforums->lang['total_capacity'] . ")";
  1099.              $info['space_free']   = $ibforums->vars['max_messages'] - $total['msg_total'];
  1100.          }
  1101.          
  1102.         
  1103.         //-----------------------------------------------
  1104.         // Write the data..
  1105.         //-----------------------------------------------
  1106.         
  1107.         $s_array = array( 's' => 5 ,
  1108.                           'm' => 7 ,
  1109.                           'l' => 15
  1110.                         );
  1111.         
  1112.         $info['NOTES'] = $this->notes ? $this->notes : $ibforums->lang['note_pad_empty'];
  1113.         
  1114.         $info['SIZE']  = $s_array[$this->size];
  1115.         
  1116.         $info['SIZE_CHOICE'] = "";
  1117.         
  1118.         //------------------------------------
  1119.         // If someone has cheated, fix it now.
  1120.         //-------------------------------------
  1121.         
  1122.         if ( empty($info['SIZE']) )
  1123.         {
  1124.             $info['SIZE'] = '5';
  1125.         }
  1126.         
  1127.         //-------------------------------------
  1128.         // Make the choice HTML.
  1129.         //-------------------------------------
  1130.         
  1131.         foreach ($s_array as $k => $v)
  1132.         {
  1133.             if ($v == $info['SIZE'])
  1134.             {
  1135.                 $info['SIZE_CHOICE'] .= "<option value='$k' selected>{$ibforums->lang['ta_'.$k]}</option>";
  1136.             }
  1137.             else
  1138.             {
  1139.                 $info['SIZE_CHOICE'] .= "<option value='$k'>{$ibforums->lang['ta_'.$k]}</option>";
  1140.             }
  1141.         }
  1142.          
  1143.          $info['NOTES'] = preg_replace( "/<br>/", "\n", $info['NOTES'] );
  1144.          
  1145.          $this->output .= $this->html->splash($info);
  1146.          
  1147.          $this->page_title = $ibforums->lang['t_welcome'];
  1148.          $this->nav        = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>" );
  1149.      }
  1150.      
  1151.      
  1152.      
  1153.      
  1154.      
  1155.      
  1156.      //*******************************************************************/
  1157.      //| UPDATE_NOTEPAD:
  1158.      //|
  1159.      //| Displays the intro screen
  1160.      //*******************************************************************/
  1161.      
  1162.      function update_notepad() {
  1163.          global $ibforums, $DB, $std, $HTTP_POST_VARS;
  1164.          
  1165.          // Do we have an entry for this member?
  1166.          
  1167.          if ($HTTP_POST_VARS['act'] == "")
  1168.         {
  1169.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
  1170.         }
  1171.         //+----------------------------------------
  1172.          
  1173.          $DB->query("SELECT id from ibf_member_extra WHERE id='".$this->member['id']."'");
  1174.          
  1175.          if ( $DB->get_num_rows() )
  1176.          { 
  1177.              $DB->query("UPDATE ibf_member_extra SET notes='".$ibforums->input['notes']."', ta_size='".$ibforums->input['ta_size']."' WHERE id='".$this->member['id']."'");
  1178.          }
  1179.          else
  1180.          {
  1181.              $DB->query("INSERT INTO ibf_member_extra (id, notes, ta_size) ".
  1182.                         " VALUES ('".$this->member['id']."', '".$ibforums->input['notes']."', '".$ibforums->input['ta_size']."')");
  1183.          }
  1184.          
  1185.          $std->boink_it($this->base_url."&act=UserCP&CODE=00");
  1186.          exit;
  1187.      }
  1188.         
  1189. }
  1190.  
  1191. ?>